package com.example.bootasync.service.impl;

import com.example.bootasync.entity.User;
import com.example.bootasync.mapper.UserMapper;
import com.example.bootasync.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author JiMing Zhou
 * @since 2023-06-01
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    /**
     * 添加积分
     * @param userId 用户id
     * @param source 新增积分
     * @return 是否成功
     */
    @Override
    public Boolean addSource(Long userId, Integer source) {
        User user = this.getById(userId);
        user.setSource(user.getSource() + source);
        return this.updateById(user);
    }
}
